/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.meraklisina.latexeditor;

import java.awt.Graphics;
import javax.swing.JSplitPane;

public class ExtendedSplitPane extends JSplitPane {
    private boolean isPainted = false;
    private boolean hasProportionalLocation = false;
    private double proportionalLocation;
    /**
     * Constructor
     */
    public ExtendedSplitPane() {
        super();
    }
    /**
     * Constructor
     * @param orientation
     */
    public ExtendedSplitPane(int orientation) {
        super(orientation);
    }
    /**
     * Sets the divider location
     * @param proportionalLocation
     */
    @Override
    public void setDividerLocation(double proportionalLocation) {
        if (!isPainted) {
            hasProportionalLocation = true;
            this.proportionalLocation = proportionalLocation;
        } else
            super.setDividerLocation(proportionalLocation);
    }
    /**
     * This is new paint method for splitpane
     * @param g
     * @see <a href="http://www.jguru.com/faq/view.jsp?EID=27191">more</a>
     */
    @Override
    public void paint(Graphics g) {
        if (!isPainted) {
            if (hasProportionalLocation)
                super.setDividerLocation(proportionalLocation);
            isPainted = true;
        }
        super.paint(g);
    }
}